<template>
    <div>
        <el-card class="box-card">
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item to="home"><span @click="clearPath">首页</span></el-breadcrumb-item>
                <el-breadcrumb-item>权限管理</el-breadcrumb-item>
                <el-breadcrumb-item>权限列表</el-breadcrumb-item>
            </el-breadcrumb>
            <el-table
                :data="rightsList"
                style="width: 100%">
                <el-table-column
                    label="#"
                    type="index"
                    width="">
                </el-table-column>
                <el-table-column
                    prop="authName"
                    label="权限名称"
                    width="">
                </el-table-column>
                <el-table-column
                    prop="path"
                    label="路径"
                    width="">
                </el-table-column>
                <el-table-column
                    prop="level"
                    label="权限等级">
                    <template slot-scope="scope">
                        <el-tag
                            v-if="scope.row.level === '0'"
                            effect="dark"
                            type="success">
                            {{ '等级一' }}
                        </el-tag>
                        <el-tag
                            v-else-if="scope.row.level === '1'"
                            effect="dark"
                            type="warning">
                            {{ '等级二' }}
                        </el-tag>
                        <el-tag
                            v-else-if="scope.row.level === '2'"
                            effect="dark"
                            type="danger">
                            {{ '等级三' }}
                        </el-tag>
                    </template>
                </el-table-column>
            </el-table>
        </el-card>
    </div>

</template>

<script>
    export default {
        name: "right",
        data() {
            return {
                rightsList: []
            }
        },
        created() {
            this.getRightsList()
        },
        methods: {
            clearPath() {
                window.sessionStorage.removeItem('path');
            },
            async getRightsList() {
                let res = await this.$http.get('rights/list')
                console.log(res)
                if (res.data.meta.status !== 200) {
                    return this.$notify.error('获取权限列表失败');
                } else {
                    this.rightsList = res.data.data;
                    this.$notify.success('成功获取权限列表');
                }
            }
        }
    }
</script>

<style scoped>

</style>
